// function GetRandomNum(Min, Max) {
//   const Range = Max - Min;
//   const Rand = Math.random();
//   return Min + Math.round(Rand * Range);
// }

// const list = new Array(5).fill(0).map((e) => GetRandomNum(1, 35));
// const list2 = new Array(2).fill(0).map((e) => GetRandomNum(1, 12)); //选两个数
// console.log(list,list2);


const convertAreas = data => {
 
  
  const temp = data
  .filter(o => !o.parentId)

  console.log('temp',temp)
   
  const provices = temp.map(o => {
      return { label: o.areaName, value: o.areaId };
    });
  provices.forEach(o => {
    const citys = data
      .filter(c => c.parentId == o.value)
      .map(c => {
        return { label: c.areaName, value: c.areaId };
      });
    o.children = citys;
  });
  return provices;
};

const data = [
    {
        "areaCode": "320000",
        "areaId": 320000,
        "areaName": "江苏省",
        "comments": "2000250",
        "parentId": undefined
    },
    {
        "areaCode": "320100",
        "areaId": 320100,
        "areaName": "南京",
        "comments": "1000250",
        "parentId": 320000
    },
    {
        "areaCode": "320102",
        "areaId": 320102,
        "areaName": "玄武区",
        "comments": "1000512",
        "parentId": 320100
    },
    {
        "areaCode": "320103",
        "areaId": 320103,
        "areaName": "白下区",
        "comments": "",
        "parentId": 320100
    },
    {
        "areaCode": "320104",
        "areaId": 320104,
        "areaName": "秦淮区",
        "comments": null,
        "parentId": 320100
    },
    {
        "areaCode": "320105",
        "areaId": 320105,
        "areaName": "建邺区",
        "comments": "320105",
        "parentId": 320100
    },
    {
        "areaCode": "320106",
        "areaId": 320106,
        "areaName": "鼓楼区",
        "comments": null,
        "parentId": 320100
    },
    {
        "areaCode": "320107",
        "areaId": 320107,
        "areaName": "下关区",
        "comments": null,
        "parentId": 320100
    },
    {
        "areaCode": "320111",
        "areaId": 320111,
        "areaName": "浦口区",
        "comments": null,
        "parentId": 320100
    },
    {
        "areaCode": "320113",
        "areaId": 320113,
        "areaName": "栖霞区",
        "comments": null,
        "parentId": 320100
    },
    {
        "areaCode": "320114",
        "areaId": 320114,
        "areaName": "雨花台区",
        "comments": null,
        "parentId": 320100
    },
    {
        "areaCode": "320115",
        "areaId": 320115,
        "areaName": "江宁区",
        "comments": "1025023",
        "parentId": 320100
    },
    {
        "areaCode": "320116",
        "areaId": 320116,
        "areaName": "六合区",
        "comments": "1025022",
        "parentId": 320100
    },
    {
        "areaCode": "320124",
        "areaId": 320124,
        "areaName": "溧水县",
        "comments": "1025024",
        "parentId": 320100
    },
    {
        "areaCode": "320125",
        "areaId": 320125,
        "areaName": "高淳县",
        "comments": "1025025",
        "parentId": 320100
    },
    {
        "areaCode": "320126",
        "areaId": 320126,
        "areaName": "其它区",
        "comments": null,
        "parentId": 320100
    },
    {
        "areaCode": "320200",
        "areaId": 320200,
        "areaName": "无锡",
        "comments": "1000510",
        "parentId": 320000
    },
    {
        "areaCode": "320202",
        "areaId": 320202,
        "areaName": "崇安区",
        "comments": null,
        "parentId": 320200
    },
    {
        "areaCode": "320203",
        "areaId": 320203,
        "areaName": "南长区",
        "comments": null,
        "parentId": 320200
    },
    {
        "areaCode": "320204",
        "areaId": 320204,
        "areaName": "北塘区",
        "comments": null,
        "parentId": 320200
    },
    {
        "areaCode": "320205",
        "areaId": 320205,
        "areaName": "锡山区",
        "comments": null,
        "parentId": 320200
    },
    {
        "areaCode": "320206",
        "areaId": 320206,
        "areaName": "惠山区",
        "comments": null,
        "parentId": 320200
    },
    {
        "areaCode": "320211",
        "areaId": 320211,
        "areaName": "滨湖区",
        "comments": null,
        "parentId": 320200
    },
    {
        "areaCode": "320281",
        "areaId": 320281,
        "areaName": "江阴",
        "comments": "1051048",
        "parentId": 320200
    },
    {
        "areaCode": "320282",
        "areaId": 320282,
        "areaName": "宜兴",
        "comments": "1051049",
        "parentId": 320200
    },
    {
        "areaCode": "320296",
        "areaId": 320296,
        "areaName": "新区",
        "comments": null,
        "parentId": 320200
    },
    {
        "areaCode": "320297",
        "areaId": 320297,
        "areaName": "其它区",
        "comments": null,
        "parentId": 320200
    },
    {
        "areaCode": "320300",
        "areaId": 320300,
        "areaName": "徐州",
        "comments": "1051632",
        "parentId": 320000
    },
    {
        "areaCode": "320302",
        "areaId": 320302,
        "areaName": "鼓楼区",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320303",
        "areaId": 320303,
        "areaName": "云龙区",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320304",
        "areaId": 320304,
        "areaName": "九里区",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320305",
        "areaId": 320305,
        "areaName": "贾汪区",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320311",
        "areaId": 320311,
        "areaName": "泉山区",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320321",
        "areaId": 320321,
        "areaName": "丰县",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320322",
        "areaId": 320322,
        "areaName": "沛县",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320323",
        "areaId": 320323,
        "areaName": "铜山县",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320324",
        "areaId": 320324,
        "areaName": "睢宁县",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320381",
        "areaId": 320381,
        "areaName": "新沂市",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320382",
        "areaId": 320382,
        "areaName": "邳州市",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320383",
        "areaId": 320383,
        "areaName": "其它区",
        "comments": null,
        "parentId": 320300
    },
    {
        "areaCode": "320400",
        "areaId": 320400,
        "areaName": "常州",
        "comments": "1051938",
        "parentId": 320000
    },
    {
        "areaCode": "320402",
        "areaId": 320402,
        "areaName": "天宁区",
        "comments": null,
        "parentId": 320400
    },
    {
        "areaCode": "320404",
        "areaId": 320404,
        "areaName": "钟楼区",
        "comments": null,
        "parentId": 320400
    },
    {
        "areaCode": "320405",
        "areaId": 320405,
        "areaName": "戚墅堰区",
        "comments": null,
        "parentId": 320400
    },
    {
        "areaCode": "320411",
        "areaId": 320411,
        "areaName": "新北区",
        "comments": null,
        "parentId": 320400
    },
    {
        "areaCode": "320412",
        "areaId": 320412,
        "areaName": "武进区",
        "comments": null,
        "parentId": 320400
    },
    {
        "areaCode": "320481",
        "areaId": 320481,
        "areaName": "溧阳市",
        "comments": "1051941",
        "parentId": 320400
    },
    {
        "areaCode": "320482",
        "areaId": 320482,
        "areaName": "金坛市",
        "comments": "1051940",
        "parentId": 320400
    },
    {
        "areaCode": "320483",
        "areaId": 320483,
        "areaName": "其它区",
        "comments": null,
        "parentId": 320400
    },
    {
        "areaCode": "320500",
        "areaId": 320500,
        "areaName": "苏州",
        "comments": "1051290",
        "parentId": 320000
    },
    {
        "areaCode": "320502",
        "areaId": 320502,
        "areaName": "沧浪区",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320503",
        "areaId": 320503,
        "areaName": "平江区",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320504",
        "areaId": 320504,
        "areaName": "金阊区",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320505",
        "areaId": 320505,
        "areaName": "虎丘区",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320506",
        "areaId": 320506,
        "areaName": "吴中区",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320507",
        "areaId": 320507,
        "areaName": "相城区",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320581",
        "areaId": 320581,
        "areaName": "常熟市",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320582",
        "areaId": 320582,
        "areaName": "张家港市",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320583",
        "areaId": 320583,
        "areaName": "昆山市",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320584",
        "areaId": 320584,
        "areaName": "吴江市",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320585",
        "areaId": 320585,
        "areaName": "太仓市",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320594",
        "areaId": 320594,
        "areaName": "新区",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320595",
        "areaId": 320595,
        "areaName": "园区",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320596",
        "areaId": 320596,
        "areaName": "其它区",
        "comments": null,
        "parentId": 320500
    },
    {
        "areaCode": "320600",
        "areaId": 320600,
        "areaName": "南通",
        "comments": "1051350",
        "parentId": 320000
    },
    {
        "areaCode": "320602",
        "areaId": 320602,
        "areaName": "崇川区",
        "comments": null,
        "parentId": 320600
    },
    {
        "areaCode": "320611",
        "areaId": 320611,
        "areaName": "港闸区",
        "comments": null,
        "parentId": 320600
    },
    {
        "areaCode": "320621",
        "areaId": 320621,
        "areaName": "海安县",
        "comments": null,
        "parentId": 320600
    },
    {
        "areaCode": "320623",
        "areaId": 320623,
        "areaName": "如东县",
        "comments": null,
        "parentId": 320600
    },
    {
        "areaCode": "320681",
        "areaId": 320681,
        "areaName": "启东市",
        "comments": null,
        "parentId": 320600
    },
    {
        "areaCode": "320682",
        "areaId": 320682,
        "areaName": "如皋市",
        "comments": null,
        "parentId": 320600
    },
    {
        "areaCode": "320683",
        "areaId": 320683,
        "areaName": "通州市",
        "comments": null,
        "parentId": 320600
    },
    {
        "areaCode": "320684",
        "areaId": 320684,
        "areaName": "海门市",
        "comments": null,
        "parentId": 320600
    },
    {
        "areaCode": "320693",
        "areaId": 320693,
        "areaName": "开发区",
        "comments": null,
        "parentId": 320600
    },
    {
        "areaCode": "320694",
        "areaId": 320694,
        "areaName": "其它区",
        "comments": null,
        "parentId": 320600
    },
    {
        "areaCode": "320700",
        "areaId": 320700,
        "areaName": "连云港",
        "comments": "1051876",
        "parentId": 320000
    },
    {
        "areaCode": "320703",
        "areaId": 320703,
        "areaName": "连云区",
        "comments": null,
        "parentId": 320700
    },
    {
        "areaCode": "320705",
        "areaId": 320705,
        "areaName": "新浦区",
        "comments": null,
        "parentId": 320700
    },
    {
        "areaCode": "320706",
        "areaId": 320706,
        "areaName": "海州区",
        "comments": null,
        "parentId": 320700
    },
    {
        "areaCode": "320721",
        "areaId": 320721,
        "areaName": "赣榆县",
        "comments": null,
        "parentId": 320700
    },
    {
        "areaCode": "320722",
        "areaId": 320722,
        "areaName": "东海县",
        "comments": null,
        "parentId": 320700
    },
    {
        "areaCode": "320723",
        "areaId": 320723,
        "areaName": "灌云县",
        "comments": null,
        "parentId": 320700
    },
    {
        "areaCode": "320724",
        "areaId": 320724,
        "areaName": "灌南县",
        "comments": null,
        "parentId": 320700
    },
    {
        "areaCode": "320725",
        "areaId": 320725,
        "areaName": "其它区",
        "comments": null,
        "parentId": 320700
    },
    {
        "areaCode": "320800",
        "areaId": 320800,
        "areaName": "淮安",
        "comments": "1051710",
        "parentId": 320000
    },
    {
        "areaCode": "320802",
        "areaId": 320802,
        "areaName": "清河区",
        "comments": null,
        "parentId": 320800
    },
    {
        "areaCode": "320803",
        "areaId": 320803,
        "areaName": "楚州区",
        "comments": null,
        "parentId": 320800
    },
    {
        "areaCode": "320804",
        "areaId": 320804,
        "areaName": "淮阴区",
        "comments": null,
        "parentId": 320800
    },
    {
        "areaCode": "320811",
        "areaId": 320811,
        "areaName": "清浦区",
        "comments": null,
        "parentId": 320800
    },
    {
        "areaCode": "320826",
        "areaId": 320826,
        "areaName": "涟水县",
        "comments": null,
        "parentId": 320800
    },
    {
        "areaCode": "320829",
        "areaId": 320829,
        "areaName": "洪泽县",
        "comments": null,
        "parentId": 320800
    },
    {
        "areaCode": "320830",
        "areaId": 320830,
        "areaName": "盱眙县",
        "comments": null,
        "parentId": 320800
    },
    {
        "areaCode": "320831",
        "areaId": 320831,
        "areaName": "金湖县",
        "comments": null,
        "parentId": 320800
    },
    {
        "areaCode": "320832",
        "areaId": 320832,
        "areaName": "其它区",
        "comments": null,
        "parentId": 320800
    },
    {
        "areaCode": "320900",
        "areaId": 320900,
        "areaName": "盐城",
        "comments": "1051564",
        "parentId": 320000
    },
    {
        "areaCode": "320902",
        "areaId": 320902,
        "areaName": "亭湖区",
        "comments": null,
        "parentId": 320900
    },
    {
        "areaCode": "320903",
        "areaId": 320903,
        "areaName": "盐都区",
        "comments": null,
        "parentId": 320900
    },
    {
        "areaCode": "320921",
        "areaId": 320921,
        "areaName": "响水县",
        "comments": null,
        "parentId": 320900
    },
    {
        "areaCode": "320922",
        "areaId": 320922,
        "areaName": "滨海县",
        "comments": null,
        "parentId": 320900
    },
    {
        "areaCode": "320923",
        "areaId": 320923,
        "areaName": "阜宁县",
        "comments": null,
        "parentId": 320900
    },
    {
        "areaCode": "320924",
        "areaId": 320924,
        "areaName": "射阳县",
        "comments": null,
        "parentId": 320900
    },
    {
        "areaCode": "320925",
        "areaId": 320925,
        "areaName": "建湖县",
        "comments": null,
        "parentId": 320900
    },
    {
        "areaCode": "320981",
        "areaId": 320981,
        "areaName": "东台市",
        "comments": null,
        "parentId": 320900
    },
    {
        "areaCode": "320982",
        "areaId": 320982,
        "areaName": "大丰市",
        "comments": null,
        "parentId": 320900
    },
    {
        "areaCode": "320983",
        "areaId": 320983,
        "areaName": "其它区",
        "comments": null,
        "parentId": 320900
    },
    {
        "areaCode": "321000",
        "areaId": 321000,
        "areaName": "扬州",
        "comments": "1000514",
        "parentId": 320000
    },
    {
        "areaCode": "321002",
        "areaId": 321002,
        "areaName": "广陵区",
        "comments": null,
        "parentId": 321000
    },
    {
        "areaCode": "321003",
        "areaId": 321003,
        "areaName": "邗江区",
        "comments": null,
        "parentId": 321000
    },
    {
        "areaCode": "321011",
        "areaId": 321011,
        "areaName": "维扬区",
        "comments": null,
        "parentId": 321000
    },
    {
        "areaCode": "321023",
        "areaId": 321023,
        "areaName": "宝应县",
        "comments": null,
        "parentId": 321000
    },
    {
        "areaCode": "321081",
        "areaId": 321081,
        "areaName": "仪征市",
        "comments": null,
        "parentId": 321000
    },
    {
        "areaCode": "321084",
        "areaId": 321084,
        "areaName": "高邮市",
        "comments": null,
        "parentId": 321000
    },
    {
        "areaCode": "321088",
        "areaId": 321088,
        "areaName": "江都市",
        "comments": null,
        "parentId": 321000
    },
    {
        "areaCode": "321092",
        "areaId": 321092,
        "areaName": "经济开发区",
        "comments": null,
        "parentId": 321000
    },
    {
        "areaCode": "321093",
        "areaId": 321093,
        "areaName": "其它区",
        "comments": null,
        "parentId": 321000
    },
    {
        "areaCode": "321100",
        "areaId": 321100,
        "areaName": "镇江",
        "comments": "1051142",
        "parentId": 320000
    },
    {
        "areaCode": "321102",
        "areaId": 321102,
        "areaName": "京口区",
        "comments": null,
        "parentId": 321100
    },
    {
        "areaCode": "321111",
        "areaId": 321111,
        "areaName": "润州区",
        "comments": null,
        "parentId": 321100
    },
    {
        "areaCode": "321112",
        "areaId": 321112,
        "areaName": "丹徒区",
        "comments": null,
        "parentId": 321100
    },
    {
        "areaCode": "321181",
        "areaId": 321181,
        "areaName": "丹阳市",
        "comments": "1051143",
        "parentId": 321100
    },
    {
        "areaCode": "321182",
        "areaId": 321182,
        "areaName": "扬中市",
        "comments": "1051144",
        "parentId": 321100
    },
    {
        "areaCode": "321183",
        "areaId": 321183,
        "areaName": "句容市",
        "comments": "1051145",
        "parentId": 321100
    },
    {
        "areaCode": "321184",
        "areaId": 321184,
        "areaName": "其它区",
        "comments": null,
        "parentId": 321100
    },
    {
        "areaCode": "321200",
        "areaId": 321200,
        "areaName": "泰州",
        "comments": "1052357",
        "parentId": 320000
    },
    {
        "areaCode": "321202",
        "areaId": 321202,
        "areaName": "海陵区",
        "comments": null,
        "parentId": 321200
    },
    {
        "areaCode": "321203",
        "areaId": 321203,
        "areaName": "高港区",
        "comments": null,
        "parentId": 321200
    },
    {
        "areaCode": "321281",
        "areaId": 321281,
        "areaName": "兴化市",
        "comments": null,
        "parentId": 321200
    },
    {
        "areaCode": "321282",
        "areaId": 321282,
        "areaName": "靖江市",
        "comments": null,
        "parentId": 321200
    },
    {
        "areaCode": "321283",
        "areaId": 321283,
        "areaName": "泰兴市",
        "comments": null,
        "parentId": 321200
    },
    {
        "areaCode": "321284",
        "areaId": 321284,
        "areaName": "姜堰市",
        "comments": null,
        "parentId": 321200
    },
    {
        "areaCode": "321285",
        "areaId": 321285,
        "areaName": "其它区",
        "comments": null,
        "parentId": 321200
    },
    {
        "areaCode": "321300",
        "areaId": 321300,
        "areaName": "宿迁",
        "comments": "1052715",
        "parentId": 320000
    },
    {
        "areaCode": "321302",
        "areaId": 321302,
        "areaName": "宿城区",
        "comments": null,
        "parentId": 321300
    },
    {
        "areaCode": "321311",
        "areaId": 321311,
        "areaName": "宿豫区",
        "comments": null,
        "parentId": 321300
    },
    {
        "areaCode": "321322",
        "areaId": 321322,
        "areaName": "沭阳县",
        "comments": null,
        "parentId": 321300
    },
    {
        "areaCode": "321323",
        "areaId": 321323,
        "areaName": "泗阳县",
        "comments": null,
        "parentId": 321300
    },
    {
        "areaCode": "321324",
        "areaId": 321324,
        "areaName": "泗洪县",
        "comments": null,
        "parentId": 321300
    },
    {
        "areaCode": "321325",
        "areaId": 321325,
        "areaName": "其它区",
        "comments": null,
        "parentId": 321300
    }
]
console.log(convertAreas(data),'res');